package com.psg.pojo;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
 *
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@TableName("car")
public class Car implements Serializable{

    /**
     *id号 （1）
     */
    @TableId(value = "id",type = IdType.AUTO)
    private Integer id;
    /**
     *用户id号（555555）
     */
    private Integer userId;
    /**
     *商品名称
     */
    private String productName;
    /**
     *商品id号（555555）
     */
    private Integer pId;
    /**
     *单价
     */
    private Float price;
    /**
     *数量
     */
    private Integer account;

    @TableField(exist = false)
    private Produce produces;


    @Override
    public String toString() {
        return "Car{" +
                "id=" + id +
                ", userId=" + userId +
                ", productName='" + productName + '\'' +
                ", pId=" + pId +
                ", price=" + price +
                ", account=" + account +
                ", produces=" + produces.toString() +
                '}';
    }

    public JSONObject toOrderJson(){
        JSONObject json = new JSONObject();
        json.put("id",this.id);
        json.put("name",this.productName);
        json.put("price",this.price);
        json.put("account",this.account);
        return json;
    }
}
